home *** CD-ROM | disk | FTP | other *** search
/ Macmillan Math: Grade 1 …Pupil's Edition (Florida) / Math Grade 1 - Pupil's Edition (Florida).iso / pc / corsair / generic / javascript / windows.js < prev   
Encoding:
JavaScript  |  2004-07-23  |  8.3 KB  |  282 lines

  1.  
  2. /*
  3. NEW CONSTANTS for PreviewBook Servlet
  4.  
  5. 0 - Preview
  6. 1 - Page ---- '/corsair/isbn/$isbn/temp/page'
  7. 2 - TOC  ---- '/corsair/isbn/$isbn/temp/toc'
  8. 3 - Media Library ---- '/corsair/isbn/$isbn/temp/medialibrary'
  9. 4 - Glossary ------ '/corsair/isbn/$isbn/temp/glossary'
  10. 5 - Asset (jpg , gif)------ *directory will be passed from the href in 'url' variable
  11. 6 - Asset (images with cations stored in ASSETHTML folder)
  12. 7 - Asset (Web) ----- * will be in the form of http:// ..... 
  13. 8 - Asset (rm) ---- * 
  14. 9 - Asset (swf)
  15. 10 - Hint  ---- '/corsair/isbn/$isbn/temp/hint'
  16.  
  17. */
  18. //alert(servletName);
  19. /*called for hint window through the servlet*/
  20.  
  21. function openHintWindow(isbn,  page ) {
  22.     var url = servletName+"?ACTION=11&FILE=" + escape(page)+".html&ISBN="+isbn;
  23.     var width = getWidth(600);
  24.     var height = 420;
  25.     var features = "scrollbars,top=0,left=0,width=" + width + ",height=" + height;
  26.     window.open(url, 'Hint', features, true).focus();
  27. }
  28.  
  29. /*called for webLinks*/
  30. function openWebWindow( url, width, height ) {    
  31.     var features = "menubar,toolbar,location,status,scrollbars,resizable";
  32.     if ( document.layers ) {
  33.         /* adjust for Netscape Navigator chrome size */
  34.         features += ",width=" + (width - 12) + ",height=" + (height - 215);
  35.     } else {
  36.         /* adjust for Internet Explorer chrome size */
  37.         features += ",width=" + (width - 12) + ",height=" + (height - 165);
  38.     }
  39. //    openWindow( url, "Asset", features, true );
  40.     window.open(url, 'Asset', features, true).focus();
  41. }
  42.  
  43.  
  44. function openMarginalWindow( isbn, marginalId, width, height ) {
  45.     if ( width < 100 ) {
  46.         width = 100;
  47.     } else {
  48.         width = getWidth( width );
  49.     }
  50.     if ( height < 100 ) {
  51.         height = 100;
  52.     }
  53.    // var url = "/BookController?ACTION=3&ISBN=" + isbn + "&TITLE=" + title + "&ID=" + marginalId;
  54.    var url = servletName+"?ACTION=3&FILE="+marginalId+".html&ISBN="+isbn;
  55.     var win = window.open(url,"Marginal","scrollbars,resizable",false);
  56.     win.resizeTo( width, height );
  57.     win.moveTo( 0, 0 );
  58.     win.focus();
  59. }
  60.  
  61.  
  62. function openPictureWindow( isbn, assetId, width, height ) {
  63.     if ( width < 100 ) {
  64.         width = 100;
  65.     } else {
  66.         width = getWidth( width );
  67.     }
  68.     if ( height < 100 ) {
  69.         height = 100;
  70.     } else {
  71.         height += 90;
  72.     }
  73.  
  74.     var url =servletName+"?ACTION=5&FILE=/corsair/isbn/"+isbn+"/temp/assethtml/"+assetId+".html";
  75.     var win = window.open(url,"Asset","scrollbars,resizable",true);
  76.     win.resizeTo( width, height );
  77.     win.moveTo( 0, 0 );
  78.     win.focus();
  79. }
  80.  
  81. function openTableContentWnd( nodeid ,isbn) {
  82.     var url = servletName+"?ACTION=1&FILE=";
  83.     if(nodeid == "0") {
  84.         url = url + "toc/tocmain.html";
  85.     }
  86.     else {
  87.         url = url +"toc/"+ nodeid + ".html";
  88.     }
  89.     url =url+"&ISBN="+isbn;
  90.     var width = getWidth(500);
  91.     var height = 495;
  92.     var features = "scrollbars,top=0,left=0,width=" + width + ",height=" + height;
  93.     window.open(url, 'Contents', features, true).focus();
  94. }
  95.  
  96. function openGlossaryWnd(word, language,isbn) {
  97.     var url = servletName+"?ACTION=2&FILE=" + language + "/";
  98.  
  99.     if (word == "default") {
  100.         url = url + "a.html";
  101.     } else {
  102.         url = url + word+".html";
  103.     }
  104.     url =url+"&ISBN="+isbn;
  105.     var width = getWidth( 450 );
  106.     var height = 200;
  107.     var features = "scrollbars,top=0,left=0,width=" + width + ",height=" + height;
  108.     window.open(url, "Glossary", features, true).focus();
  109. }
  110.  
  111. function openAssetHtmlWindow( isbn, marginalId, features, width, height ) {
  112.     if ( width < 100 ) {
  113.         width = 100;
  114.     } else {
  115.         width = getWidth( width );
  116.     }
  117.     if ( height < 100 ) {
  118.         height = 100;
  119.     }
  120.  
  121.     var url = servletName+"?ACTION=12&FILE="+marginalId+".html&ISBN="+isbn;
  122.     var win = window.open(url,"Asset",features,false);
  123.     win.resizeTo( width+120, height+120 );
  124.     win.moveTo( 0, 0 );
  125.     win.focus();  
  126. }
  127.  
  128. function openAssetWindow( url, features, width, height ) {
  129.     
  130.     if ( width < 100 ) {
  131.         width = 100;
  132.     } else if ( ( features == "scrollbars" ) || ( features == "resizable,scrollbars" ) ) {
  133.         width = getWidth( width );
  134.         height = getHeight( height );
  135.     }    
  136.     if ( height < 100 ) height = 100;    
  137.     if (width <= 770) width = width + 22;
  138.     if (height <= 565) height = height + 35;
  139.     var win = window.open(url,'Asset',features,true);
  140.     win.resizeTo( width, height );
  141.     win.moveTo( 0, 0 );
  142.     win.focus();
  143. }
  144.  
  145. function openAnswerWindow( isbn, text ) 
  146. {
  147.     openMarginalWindow( isbn, text, "Answer", 370, 190 );
  148. }
  149.  
  150. function openMediaLibraryWnd( nodeid,isbn ) 
  151. {
  152.    var url = servletName+"?ACTION=13&FILE="+nodeid;
  153.    url =url+"&ISBN="+isbn;
  154.    var width = getWidth(500);
  155.    var height = 495;
  156.    var features = "scrollbars,top=0,left=0,width=" + width + ",height=" + height;
  157.    var win = window.open(url, 'MediaLibrary', features, false); 
  158. }
  159.  
  160. function openBookResourceWnd( nodeid,isbn ) 
  161. {    
  162.     var url = servletName+"?ACTION=9&FILE="+nodeid+".html";
  163.     url =url+"&ISBN="+isbn;
  164.     var width = getWidth(600);
  165.     var height = 550;
  166.     var features = "scrollbars,top=0,left=0,width=" + width + ",height=" + height;
  167.     window.open(url, 'BookResources', features, true).focus();
  168. }
  169.  
  170. function isValidPage( isbn, page ) 
  171. {
  172.     if ( sample ) {
  173.         openSampleMsgWindow();
  174.         return false;
  175.     }
  176.     var hasChars = ( page.toLowerCase() != page.toUpperCase() );
  177.     var regexp = new RegExp( "_" + page + "_", "i" );
  178.     var validPage = false;
  179.     if ( hasChars ) {
  180.         validPage = regexp.test( charPages );
  181.     } else {
  182.         validPage = ( page >= minPage ) && ( page <= maxPage ) && !regexp.test( gapPages );
  183.     }
  184.     if ( !validPage ) {
  185.         openErrorWnd( isbn, page );
  186.     }
  187.     return validPage;
  188. }
  189.  
  190.  
  191. // compensate for IE scollbar width 
  192. function getWidth( width ) {    
  193.     if ( !document.layers ) {
  194.         width += 28;
  195.     }
  196.     return width;
  197. }
  198.  
  199.  
  200. function getHeight( height ) {
  201.     if ( !document.layers ) {
  202.         height += 35;
  203.     } else {
  204.         height += 13;
  205.     }
  206.     return height;
  207. }
  208.  
  209. function TWE(tweisbn, twepagenum)
  210. {
  211.     
  212.     if(tweisbn != ''){
  213. //        if (window.opener != null){
  214.         //    userType = window.opener.document.onlinecontent.userType.value;
  215.             //userType = 1;
  216.             //alert(userType);
  217.             if ((userType== 1)  || (userType== 3)  || (userType== 6) || (userType== 8)  || (userType== 10) ){            
  218.             document.write("<a href='javascript:void(0);' onclick=\"javascript:openTWEPage('"+tweisbn+"','"+twepagenum+"')\">");
  219.             //document.write("<img src='../../../../generic/images/page/teachereditionicon.gif' alt='Teacher Edition' border='0'/>");
  220.             document.write("</a>");
  221. //            } 
  222.         }
  223.     }
  224. }
  225.  
  226.  
  227. function TWEPDF(tweisbn, twepagenum, fileexnt)
  228. {
  229.     if(tweisbn != ''){
  230.             userType = 1;
  231.             if ((userType== 1)  || (userType== 3)  || (userType== 6) || (userType== 8)  || (userType== 10) ){            
  232.             document.write("<a href='javascript:void(0);' onclick=\"javascript:openTWEPDFPage('"+tweisbn+"','"+twepagenum+"','"+fileexnt+"' )\">");
  233.             //document.write("<img src='../../../../generic/images/page/teachereditionicon.gif' alt='Teacher Edition' border='0'/>");
  234.             document.write("</a>");
  235.         }
  236.     }
  237. }
  238.  
  239.  
  240. function openTWEPDFPage(tweisbn, twepagenum, fileexnt)
  241. {
  242.  var features = "toolbar=no,scrollbars=yes,left=0,top=0,resizable=no,width=600,height=540";
  243.  var url = servletName+"?ACTION=0&ISBN="+tweisbn+"&FILE="+twepagenum+"."+fileexnt;
  244.  var win = window.open(url,"TeachEdition",features,true);
  245.     win.moveTo( 0, 0 );
  246.     win.focus();
  247. }
  248.  
  249.  
  250. function openTWEPage(tweisbn, twepagenum)
  251. {
  252.  var features = "toolbar=no,scrollbars=yes,left=0,top=0,resizable=no,width=241,height=540";
  253.  var url = servletName+"?ACTION=0&ISBN="+tweisbn+"&FILE="+twepagenum+".html";
  254.  var win = window.open(url,"TeachEdition",features,true);
  255.     win.moveTo( 0, 0 );
  256.     win.focus();
  257. }
  258.  
  259. function openAssessmentWnd(assessname, foldername, isbn)
  260. {
  261.   var url = servletName +"?ACTION=7&FILE=" + foldername + "/" + assessname + ".html&ISBN="+isbn;
  262.   var features = 'width=' + getWidth(500) + ',height=' + 495 + ',scrollbars,menubar,toolbar';
  263.   window.open(url, 'Assessment', features, true ).focus();
  264. }
  265.  
  266. function openMathKeyWnd()
  267. {
  268.   var url = servletName +"?ACTION=0&FILE=temp.html";
  269.   var features = 'width=' + getWidth(480) + ',height=' + 550 + ',scrollbars=no,titlebar=no,toolbar=no';
  270.   window.open(url, 'MathKeyPad', features, true ).focus();
  271. }
  272.  
  273. function onMessage1(data)
  274. {
  275.     var imgs = document.images;
  276.     for(var i=0; i < imgs.length; i++ )
  277.         if(imgs[i].name == 'Q40A10') 
  278.         {
  279.             var filename = "C:\\mkp\\images\\"+data;
  280.             imgs[i].src = filename;
  281.         }
  282. }